using System.Collections.ObjectModel;
using HMCollada.FX;
using System.Xml;

namespace HMCollada.FX {
    internal struct HMColladaInstanceEffect {
        internal string sid;
        internal string name;
        internal string url;
        internal Collection<HMColladaTechniqueHint> technique_hint;
        internal Collection<HMColladaSetParam> setparam;
    }
}

namespace HMCollada {
    internal partial class HMColladaLoader {
        private static HMColladaInstanceEffect LoadInstanceEffect() {
            HMColladaInstanceEffect newInstanceEffect = new HMColladaInstanceEffect();
            newInstanceEffect.sid = colladaReader.GetAttribute("sid");
            newInstanceEffect.name = colladaReader.GetAttribute("name");
            newInstanceEffect.url = colladaReader.GetAttribute("url");

            newInstanceEffect.technique_hint = new Collection<HMColladaTechniqueHint>();
            newInstanceEffect.setparam = new Collection<HMColladaSetParam>();

            if (!colladaReader.IsEmptyElement) colladaReader.Read();
            do {
                if (colladaReader.NodeType != XmlNodeType.EndElement) {
                    switch (colladaReader.Name) {
                        case "setparam": newInstanceEffect.setparam.Add(LoadSetParam()); break;
                        case "technique_hint": newInstanceEffect.technique_hint.Add(LoadTechniqueHint()); break;
                    }
                }

                if (!colladaReader.IsEmptyElement) colladaReader.Read();
            } while (colladaReader.Name != "instance_effect");

            if (colladaReader.IsEmptyElement) colladaReader.Read();
            return newInstanceEffect;
        }
    }
}